﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brain.Editor;
using Brain.Rendering;
using Microsoft.Xna.Framework.Graphics;

namespace Brain.Plugins
{
    public class DefaultRenderManager3DPlugin : IEditorPlugin
    {
        public string[] RelativeDLLs
        {
            get { return null; }
        }

        public void Load()
        {
            Engine.Instance.AddManager(new DefaultRenderManager3D(Engine.Instance.GraphicsDevice));
            GameScreen s = Engine.Instance.ScreenManager.GetScreen(0);
            if (s != null)
            {
                InputFreeCamera3D free = new InputFreeCamera3D(s);
                free.ShouldSerialize = false;
                
                free.FarPlane = 10000;
                free.NearPlane = 1;
                PresentationParameters pp = Engine.Instance.GraphicsDevice.PresentationParameters;
                free.AspectRatio = pp.BackBufferWidth / (float)pp.BackBufferHeight;

                Engine.Instance.CameraManager.Camera3D = free;
            }
        }


        public void Reload()
        {
            Engine.Instance.AddManager(new DefaultRenderManager3D(Engine.Instance.GraphicsDevice));
        }

        public void EndReload()
        {
            GameScreen s = Engine.Instance.ScreenManager.GetScreen(0);
            if (s != null)
            {
                InputFreeCamera3D free = new InputFreeCamera3D(s);
                free.ShouldSerialize = false;

                free.FarPlane = 10000;
                free.NearPlane = 1;
                PresentationParameters pp = Engine.Instance.GraphicsDevice.PresentationParameters;
                free.AspectRatio = pp.BackBufferWidth / (float)pp.BackBufferHeight;

                Engine.Instance.CameraManager.Camera3D = free;
            }
        }


        public void Disable()
        {
            throw new NotImplementedException();
        }
    }
}
